package com.thinkingstar.core.support.views;

import org.beetl.core.GroupTemplate;
import org.beetl.core.Template;
import org.beetl.ext.web.WebRenderExt;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author : sy
 * @Description :
 * @Date : Created in 11:47 2018/4/17
 */
public class BeetlGlobalExt implements WebRenderExt {

    static long version = System.currentTimeMillis();

    @Override
    public void modify(Template template, GroupTemplate groupTemplate, HttpServletRequest request, HttpServletResponse response) {
        response.setBufferSize(1024*24);
        HttpServletRequest httpRequest=(HttpServletRequest)request;
        String path = "http://" + request.getServerName() //服务器地址
                + ":"
                + request.getServerPort()            //端口号
                + httpRequest.getContextPath();      //项目名称 ;
        template.binding("ctx",path);
        template.binding("version",version); //js,css 的版本编号
    }
}
